package mytest;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Area_overlap {

	static class Node{
		int left,right;
	}
	
	
	static Node[] arr=new Node[100];
	
	static int N;
	
	static boolean solve(int left,int right)
	{
		//排序
		Arrays.sort(arr, 0, N, new Comparator<Node>(){
			public int compare(Node o1, Node o2) {
				return o1.left-o2.left;
			}
		});
		
		//合并区间
		int total=0;
		Node tmp=arr[0];
		for(int i=1;i<N;i++)
		{
			if(arr[i].left<=tmp.right&&arr[i].right>tmp.right)
			{
				tmp.right=arr[i].right;
			}else if(arr[i].left>tmp.right)
			{
				arr[total++]=tmp;
				tmp=arr[i];
			}
		}
		arr[total++]=tmp;
		//二分查找
		int start=0,end=total-1;
		while(start<=end)
		{
			int mid=(start+end)>>1;
			if(arr[mid].left>left)end=mid-1;
			else if(arr[mid].right<left)start=mid+1;
			else if(right<=arr[mid].right) return true;
			else return false;
		}
		return false;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		N=Integer.parseInt(bf.readLine());
		for(int i=0;i<N;i++)
		{
			StringTokenizer st=new StringTokenizer(bf.readLine());
			int left=Integer.parseInt(st.nextToken());
			int right=Integer.parseInt(st.nextToken());
			Node n=new Node();
			if(left<=right)
			{
				n.left=left;
				n.right=right;
			}else{
				n.left=right;
				n.right=left;
			}
			arr[i]=n;
		}
		StringTokenizer st=new StringTokenizer(bf.readLine());
		int left=Integer.parseInt(st.nextToken());
		int right=Integer.parseInt(st.nextToken());
		if(solve(Math.min(left, right),Math.max(left, right)))System.out.println(true);
		else System.out.println(false);
	}

}
